﻿-- =============================================
-- This script will upgrade Audit Tables
-- to use Partitions only if the deployment is 
-- executing on an Enterprise Edition of SQL
-- =============================================
IF SERVERPROPERTY('EngineEdition') = 3
	PRINT 'Partitioning tables, this operation may take awhile.'
GO

IF SERVERPROPERTY('EngineEdition') = 3 AND dbo.sf_system_IsTablePartitioned(N'Audit_Role') = 0
	PRINT 'Partitioning RoleAudit table.'
GO

--Every other value does not support Partitioning.
IF SERVERPROPERTY('EngineEdition') = 3
BEGIN 
	--Check if RoleAudit table has been Partitioned already.
	IF (dbo.sf_system_IsTablePartitioned(N'Audit_Role') = 0)
	BEGIN
		EXEC System_PartitionTable N'Audit_Role', N'PScheme_Audit', N'RAU_ModificationDate' 
	END

END 